package face.pay.security.util;

import face.pay.entity.UserInfo;
import face.pay.security.token.UserNamePasswordToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Auther: zkj
 * @Date: 2019/7/2 14:34
 * @Description:
 */
public class SecurityUserUtil {

    public  static UserInfo getCurrentLoginUser(){

        UserNamePasswordToken obj =  (UserNamePasswordToken) SecurityContextHolder.getContext().getAuthentication();

        if(obj!=null){
            return  obj.getCurrentUser();
        }
        return  null;
    }

    public Integer getCurrentOemId(){

        UserInfo currentUser = getCurrentLoginUser();
        if(currentUser!=null){
            return  currentUser.getOemId();
        }
        return  null;
    }
}
